﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web.Script.Services;

namespace Orbitone.MeetingRooms.ExchangeService
{
    [DataContract(Name = "CalendarItem", Namespace = "")]
    public class CalendarItem
    {
        [DataMember(EmitDefaultValue = true, Order = 1)]  
        public int Id { get; set; }

        [DataMember(EmitDefaultValue = false, Order = 2)] 
        public string Description { get; set; }

        [DataMember(Name = "StartDate", EmitDefaultValue = false, Order = 3)] 
        public string StartDate{ get; set; }

        [DataMember(Name = "EndDate", EmitDefaultValue = false, Order = 4)] 
        public string EndDate { get; set; }

        [DataMember(Name = "Rand", EmitDefaultValue = false, Order = 5)] 
        public int Rand { get; set; }

        [DataMember(Name = "Recurring", EmitDefaultValue = false, Order = 6)] 
        public int Recurring { get; set; }

        [DataMember(Name = "Rand2", EmitDefaultValue = false, Order = 7)] 
        public int Rand2 { get; set; }

        [DataMember(Name = "Editable", EmitDefaultValue = false, Order = 8)] 
        public int Editable { get; set; }

        [DataMember(Name = "Location", EmitDefaultValue = false, Order = 9)] 
        public string Location { get; set; }

        [DataMember(Name = "Attends", EmitDefaultValue = false, Order = 10)] 
        public string Attends { get; set; }

    }

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ExchangeService : IExchangeService
    {
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        public string Method()
        {
            return "test";
            //DataContractJsonSerializer
            //return new List<CalendarItem>
            //           {
            //               new CalendarItem
            //                   {
            //                       Id = 86072,
            //                       Description = "annual report",
            //                       StartDate = DateTime.Now.ToString("dd/MM/yyyy hh:mm"),
            //                       EndDate = DateTime.Now.AddHours(3).ToString("dd/MM/yyyy hh:mm"),
            //                       Rand = 0,
            //                       Recurring = 0,
            //                       Rand2 = 5,
            //                       Editable = 1,
            //                       Location = "Test",
            //                       Attends = ""
            //                   }
            //           };
        }
    }
}
